package cn.javass.dp.flyweight.example4;

/**
 * 将封装重复的数据作为享元对象
 */
public class AuthorizationFlyweight implements Flyweight {

    private String securityEntity;

    private String premit;

    public AuthorizationFlyweight(String state) {
        String ss[] = state.split(",");
        securityEntity = ss[0];
        premit = ss[1];
    }

    public String getSecurityEntity() {
        return securityEntity;
    }

    public String getPremit() {
        return premit;
    }

    @Override
    public boolean match(String securityEntity, String premit) {
        if (this.securityEntity.equals(securityEntity) && this.premit.equals(premit)) {
            return true;
        }
        return false;
    }

    @Override
    public void add(Flyweight f) {
        throw new UnsupportedOperationException("对象不支持这个功能");
    }
}
